﻿<UserControl x:Class="AutomationMLMapper.Controls.EngineNotifications"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ConvertersAndTemplateSelectors="clr-namespace:AutomationMLMapper.Controls.ConvertersAndTemplateSelectors" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/AutomationMLMapper;component/StyleResources/ListStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Text="{Binding Name}" Style="{StaticResource HeaderTextBlock}" ></TextBlock>
        <Button Content="X" Grid.Row="0" Margin="2" Style="{StaticResource HeaderButtonStyle}" FontFamily="Courier" 
                FontSize="9" FontWeight="Bold" Padding="0" Click="ButtonClick"></Button>
        <ListBox Grid.IsSharedSizeScope="True"  x:Name="MessageList" IsSynchronizedWithCurrentItem="True" Grid.Row="1" ItemsSource="{Binding}">
            
            <ListBox.Resources>
                <ConvertersAndTemplateSelectors:SplitMessageConverter x:Key="SplitMessageConverter"></ConvertersAndTemplateSelectors:SplitMessageConverter>
            </ListBox.Resources>
            
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalAlignment" Value="Stretch" />
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border Style="{StaticResource ListItemBorderStyle}">                        
                        <Grid>                            
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition SharedSizeGroup="col1"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="col2"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" FontWeight="Bold" Padding="2" 
                                       Text="{Binding Converter={StaticResource SplitMessageConverter}, ConverterParameter=0}"></TextBlock>

                            <TextBlock Grid.Column="1" Padding="2" TextWrapping="Wrap" HorizontalAlignment="Left" MaxWidth="550"
                                       Text="{Binding Converter={StaticResource SplitMessageConverter}, ConverterParameter=1}"></TextBlock>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
